SQLiteAggregateFunction<T1,T2,TResult> Class
Generic base class for user-defined aggregate functions with two parameters.
This example illustrates creating and using user-defined function for calculating Average value. Step method is used to accumulate sum of values and iteration count, and Complete method is used to divide sum by iteration count.
public class MyFunction : SQLiteAggregateFunction<long, double> {
private long count;
public MyFunction() : base("Average") {
count = 0;
}
public override void Step(long arg1, SQLiteConnection connection, ref double contextData) {
contextData = contextData + arg1;
count++;
}
public override double Complete(SQLiteConnection connection, double contextData) {
return contextData / count;
}
}